From 2cb49001bc68da3461a5250d609fbdf56e2afa83 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Sat, 10 Mar 2007 23:22:00 +0000 Subject: [PATCH] Added an VM_HVM_REQUIRED error code, and use it on VM.start. Signed-off-by: Ewan Mellor --- docs/xen-api/xenapi-datamodel.tex | 12 +++++++++++- tools/python/xen/xend/XendAPI.py | 11 +++++++---- tools/python/xen/xend/XendDomainInfo.py | 7 ++++++- tools/python/xen/xend/XendError.py | 7 +++++++ tools/python/xen/xend/image.py | 5 ++--- tools/python/xen/xm/messages/en/xen-xm.po | 5 ++++- 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/docs/xen-api/xenapi-datamodel.tex b/docs/xen-api/xenapi-datamodel.tex index 08b831fdd5..ed6e0081b6 100644 --- a/docs/xen-api/xenapi-datamodel.tex +++ b/docs/xen-api/xenapi-datamodel.tex @@ -1141,7 +1141,8 @@ void \vspace{0.3cm} -\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE} +\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}, {\tt +VM\_HVM\_REQUIRED} \vspace{0.6cm} \subsubsection{RPC name:~pause} @@ -13337,6 +13338,15 @@ expected and actual VM state at the time of the call. \begin{verbatim}VM_BAD_POWER_STATE(vm, expected, actual)\end{verbatim} \begin{center}\rule{10em}{0.1pt}\end{center} +\subsubsection{VM\_HVM\_REQUIRED} + +HVM is required for this operation + +\vspace{0.3cm} +{\bf Signature:} +\begin{verbatim}VM_HVM_REQUIRED(vm)\end{verbatim} +\begin{center}\rule{10em}{0.1pt}\end{center} + \newpage diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py index bf5f9a8a2f..2d7a01bc1a 100644 --- a/tools/python/xen/xend/XendAPI.py +++ b/tools/python/xen/xend/XendAPI.py @@ -1465,10 +1465,13 @@ class XendAPI(object): start_paused = start_paused) def VM_start(self, session, vm_ref, start_paused): - return XendTask.log_progress(0, 100, do_vm_func, - "domain_start", vm_ref, - start_paused = start_paused) - + try: + return XendTask.log_progress(0, 100, do_vm_func, + "domain_start", vm_ref, + start_paused = start_paused) + except HVMRequired, exn: + return xen_api_error(['VM_HVM_REQUIRED', vm_ref]) + def VM_suspend(self, session, vm_ref): return XendTask.log_progress(0, 100, do_vm_func, "domain_suspend", vm_ref) diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 1842143d79..13a7a20f58 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -1489,7 +1489,12 @@ class XendDomainInfo: self.info['start_time'] = time.time() self._stateSet(DOM_STATE_RUNNING) - except (RuntimeError, VmError), exn: + except VmError, exn: + log.exception("XendDomainInfo.initDomain: exception occurred") + if self.image: + self.image.cleanupBootloading() + raise exn + except RuntimeError, exn: log.exception("XendDomainInfo.initDomain: exception occurred") if self.image: self.image.cleanupBootloading() diff --git a/tools/python/xen/xend/XendError.py b/tools/python/xen/xend/XendError.py index f1507c43dc..bbd5f4f6dd 100644 --- a/tools/python/xen/xend/XendError.py +++ b/tools/python/xen/xend/XendError.py @@ -13,6 +13,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #============================================================================ # Copyright (C) 2004, 2005 Mike Wray +# Copyright (c) 2006, 2007 XenSource Inc. #============================================================================ from xmlrpclib import Fault @@ -55,6 +56,12 @@ class VmError(XendError): """Vm construction error.""" pass +class HVMRequired(VmError): + def __init__(self): + XendError.__init__(self, + 'HVM guest support is unavailable: is VT/AMD-V ' + 'supported by your CPU and enabled in your BIOS?') + XEND_ERROR_AUTHENTICATION_FAILED = ('ELUSER', 'Authentication Failed') XEND_ERROR_SESSION_INVALID = ('EPERMDENIED', 'Session Invalid') diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index f39e842f2b..33e1b1100b 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -24,7 +24,7 @@ import signal import xen.lowlevel.xc from xen.xend.XendConstants import REVERSE_DOMAIN_SHUTDOWN_REASONS -from xen.xend.XendError import VmError, XendError +from xen.xend.XendError import VmError, XendError, HVMRequired from xen.xend.XendLogging import log from xen.xend.XendOptions import instance as xenopts from xen.xend.server.netif import randomMAC @@ -274,8 +274,7 @@ class HVMImageHandler(ImageHandler): info = xc.xeninfo() if 'hvm' not in info['xen_caps']: - raise VmError("HVM guest support is unavailable: is VT/AMD-V " - "supported by your CPU and enabled in your BIOS?") + raise HVMRequired() self.dmargs = self.parseDeviceModelArgs(vmConfig) self.device_model = vmConfig['platform'].get('device_model') diff --git a/tools/python/xen/xm/messages/en/xen-xm.po b/tools/python/xen/xm/messages/en/xen-xm.po index 3ea171b2fa..6e289b4aa3 100644 --- a/tools/python/xen/xm/messages/en/xen-xm.po +++ b/tools/python/xen/xm/messages/en/xen-xm.po @@ -19,7 +19,7 @@ msgid "" msgstr "" "Project-Id-Version: Xen-xm 3.0\n" -"PO-Revision-Date: 2007-02-20 15:22+0000\n" +"PO-Revision-Date: 2007-03-10 23:17+0000\n" "Last-Translator: Ewan Mellor \n" "Language-Team: xen-devel \n" "MIME-Version: 1.0\n" @@ -61,3 +61,6 @@ msgstr "The VLAN tag you gave (%(1)s) is invalid -- it must be between 0 and 409 msgid "VM_BAD_POWER_STATE" msgstr "The VM must be %(2)s to perform the requested operation (it is currently %(3)s)." + +msgid "VM_HVM_REQUIRED" +msgstr "HVM guest support is unavailable: is VT/AMD-V supported by your CPU and enabled in your BIOS?" -- 2.30.2